<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <title>克隆优化节点操作</title>
  </head>

  <body>
    <p id="box1">abc</p>
    <script>
      for (var i = 0; i < 3; i++) {
        var p = document.createElement("p");
        p.innerHTML = i;
        document.body.appendChild(p);
      }

      //使用克隆(优)
      var oldP = document.getElementById("box1");
      for (var i = 0; i < 3; i++) {
        var newP = oldP.cloneNode(false); //克隆原有标签
        newP.innerHTML = i;
        document.body.appendChild(newP);
      }
    </script>
  </body>
</html>
